

import java.util.Arrays;
import java.util.Scanner;

public class QuickSort {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int len = sc.nextInt();
            sc.nextLine();
            String[] s = sc.nextLine().split(" ");
            int[] nums = new int[len];
            for (int i = 0; i < len; i++) {
                nums[i] = Integer.parseInt(s[i]);
            }
            System.out.println(Arrays.toString(quickSort(nums, 0 , len-1)));
        }


    }

    public static int[] quickSort(int[] arr,int low,int high) {
        // 递归出口
        if (low >= high) {
            return  arr;
        }

        int i = low, j = high;
        int pivot = arr[low];
        while (i < j) {
            // 注意一定要j在前面。最终一定是i==j，但是要保证i==j<=pivot
            while (arr[j] >= pivot && i < j) {
                j--;
            }
            while (arr[i] <= pivot && i < j) {
                i++;
            }
            if (i < j) {
                int tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
            }
        }
        arr[low] = arr[i];
        arr[i] = pivot;
        quickSort(arr, low, j-1);
        quickSort(arr, j+1, high);
        return arr;
    }

}
